package com.firstgroup.repository;

import com.firstgroup.domain.Evaluate;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface EvaluateRepository extends JpaRepository<Evaluate,Integer> {

    Evaluate findByInterviewerId(int InterviewerId);


    /**
     * 遍历平均分
     * @param interviewerId
     * @param state
     * @return
     */
    @Query(value = "select AVG(e.heart),AVG(e.communicate),AVG(e.study),AVG(e.strain)," +
            "AVG(e.compression),AVG(e.attitude),AVG(e.understand),AVG(e.sum)  " +
            "from Evaluate e where e.interviewerId=?1 and e.value=?2")
    List<Object[]> find(int interviewerId,String state);

    /**
     * 根据状态和id遍历分数
     * @param interviewerId
     * @param value
     * @return
     */
    List<Evaluate> findByInterviewerIdAndValue(int interviewerId,String value);


}
